package com.geekchique.runningbuddy.view.dayofjogdetails;

import java.util.LinkedList;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.geekchique.runningbuddy.activity.stopclock.StopClockTools;
import com.geekchique.runningbuddy.model.Jog;
import com.geekchique.runningbuddy.view.JogEntryView;

public class DayOfJogDetailsListAdapter extends BaseAdapter{

	private LinkedList<Jog> jogEntries;
	private final Context activity;
    

	public DayOfJogDetailsListAdapter(Context activity, LinkedList<Jog> jogEntries) {
		this.activity = activity;
		this.jogEntries = jogEntries;
	}

	public int getCount() {
		return this.jogEntries.size();
	}

	public Jog getItem(int position) {
		return this.jogEntries.get( position);
	}

	public long getItemId(int position) {
		return this.jogEntries.get(position)._id;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		
	    TextView miles;
	    TextView jogname;
	    TextView timerun;
		
        miles = new TextView(activity);
        miles.setText("00");
        
        jogname = new TextView(activity);
        jogname.setText(jogEntries.get(position).name);
        
        timerun = new TextView(activity);
        timerun.setText(StopClockTools.getFormattedDiff(jogEntries.get(position).getStartTime(), jogEntries.get(position).getStopTime()));
        
		JogEntryView todayView = new JogEntryView(activity, miles, jogname, timerun);
		return todayView;
	}

}
